home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------------
- '
- ' Microsoft Windows Media
- ' Copyright (C) Microsoft Corporation. All rights reserved.
- '
- ' File: WMSCommon.js
- '
- ' Contents: Included by nearly all WMS Admin .asp files
- '
- '--------------------------------------------------------------------------*/
-
- /*@cc_on @*/
-
- var g_dwLastTimerTask = 0;
- var g_rgDivVisited = null;
- var g_dwNumHelpLoadAttempts = 0;
- var g_bDisplayingError = false;
- var g_bDebugMode = false;
- var g_winHelp = null;
-
- var g_bMSIE, g_bNetscape, g_bOpera;
- g_bMSIE = ( -1 != window.navigator.appName.indexOf( "IE" ) ) || ( -1 != window.navigator.appName.indexOf( "Microsoft" ) );
- g_bNetscape = ( -1 != window.navigator.appName.indexOf( "Netscape" ) );
- g_bOpera = ( -1 != window.navigator.appName.indexOf( "Opera" ) );
-
- window.status = "";
-
- if( true == g_bMSIE )
- {
- window.onerror=fnErrHandler;
- }
- else if( true == g_bNetscape )
- {
- document.onmouseup=void( 0 );
- }
-
- ///////////////////////////
- function fnErrHandler( sMsg, sUrl, sLine )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- if( g_bDebugMode )
- {
- if( g_bDisplayingError )
- {
- return( true );
- }
-
- g_bDisplayingError = true;
- window.alert( "Windows Media Services\n\nError: " + sMsg + "\nPage: " + sUrl + "\nLine: " + sLine );
- g_bDisplayingError = false;
- }
- return( true );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function RemoveBad( szTemp )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var szSafeString = new String( szTemp );
- szSafeString = szTemp.replace( /\<|\>|\"|\%|\;|\(|\)|\&|\+|\-/g, "" );
- return( szSafeString );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function EscapeTheBackslashCharacter( szUnfiltered )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var szSafe = new String( szUnfiltered );
- szSafe = szUnfiltered.replace( /\\&/g, "\\" );
- return( szSafe );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function RemoveDangerousCharacters( szUnfiltered )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var szSafe = new String( szUnfiltered );
- var re = /\<|\>|\*|\%|\;|\(|\)|\"|\u201C|\u201D|\u201E|\"\&/gim;
- szSafe = szUnfiltered.replace( re, "" );
- return( szSafe );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function ShowHideSecureWarning( szPathToImg, szWarningText )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- if( parent.frames && parent.frames[ "treeFrames" ] && parent.frames && parent.frames[ "treeFrames" ].frames[ "frameTreeCode" ] )
- {
- return;
- }
- document.write( "<td align=left valign=top>" );
- document.write( "<a href=\"" + document.location.protocol + "//" + parent.document.location.host + "/nonsecure.asp" + "\" target=\"sList\" style=\"position:absolute;right:15;top:10\" border=0><img alt=\"" + szWarningText + "\" border=0 height=32 width=32 src=" + szPathToImg + " ></a>" );
- document.write( "</td> " );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function SafeUnescape( szInput )
- {
- var szRetVal;
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- szRetVal = new String( szInput );
- if( 0 == szRetVal.length )
- {
- return( "" );
- }
- /*@if (@_jscript_version >= 5.5)
- szRetVal = decodeURIComponent( szRetVal );
- @else @*/
- szRetVal = unescape( szRetVal );
- /*@end @*/
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return( szRetVal );
- }
-
- ///////////////////////////
- function SafeEscape( szInput )
- {
- var szRetVal;
- var szUnescapedVal;
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- szRetVal = new String( szInput );
- if( 0 == szRetVal.length )
- {
- return( "" );
- }
-
- // prevent dbl-escape bugs
- szUnescapedVal = SafeUnescape( szInput );
- if( szUnescapedVal != szInput )
- {
- return( szInput );
- }
- /*@if (@_jscript_version >= 5.5)
- szRetVal = encodeURIComponent( szRetVal );
- @else @*/
- szRetVal = escape( szRetVal );
- /*@end @*/
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return( szRetVal );
- }
-
- ///////////////////////////
- function FileFromPath( szPath )
- {
- var dwLastPosOfSlash = 0;
- var dwPosOfSlash = 0;
- var szPathStr = new String( szPath );
- dwPosOfSlash = szPathStr.lastIndexOf( "/" );
- return( szPathStr.slice( dwPosOfSlash + 1 ) );
- }
-
- ///////////////////////////
- function EatHelpCookie( szTopic )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var cookieParent = null;
- if( ( null == g_winHelp ) || ( 2 > g_winHelp.frames.length ) )
- {
- return;
- // cookieParent = window.document;
- }
- else
- {
- cookieParent = g_winHelp.document;
- }
-
- var expiredDate = new Date();
- expiredDate.setMinutes( expiredDate.getMinutes() - 2 );
-
- var szCurrentTopic = document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + szTopic;
- cookieParent.cookie = "helpTreeActiveTopic=; expires=" + expiredDate.toUTCString() + "; secure=false;";
- cookieParent.cookie = "helpTreeActiveURL=; expires=" + expiredDate.toUTCString() + "; secure=false;";
- // cookieParent.cookie = "helpTreeOpenNodes=; expires=" + expiredDate.toUTCString() + "; secure=false;";
-
- var newDate = new Date();
- newDate.setUTCDate( newDate.getUTCMinutes() + 15 );
- cookieParent.cookie = "helpTreeActiveURL=" + szTopic + "; expires=" + newDate.toUTCString() + ";";
-
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function LoadHelpTopic( szTopic )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- if( null == g_winHelp )
- {
- return;
- }
-
- var dwNumFrames = 0;
- var mainFrame = null;
- dwNumFrames = g_winHelp.frames.length;
- mainFrame = g_winHelp.frames[ "main" ];
-
- if( ! mainFrame )
- {
- if( g_dwNumHelpLoadAttempts < 3 )
- {
- g_dwNumHelpLoadAttempts = g_dwNumHelpLoadAttempts + 1;
-
- var szOperation = "LoadHelpTopic( " + "'" + szTopic + "'" + ");";
- setTimeout( szOperation, 500, "JavaScript" );
- }
- return;
- }
-
- mainFrame.location.replace( szTopic );
-
- if( FileFromPath ( mainFrame.location.pathname ) != FileFromPath ( szTopic ) )
- {
- if( "default.htm" == FileFromPath ( mainFrame.location.pathname ) )
- {
- mainFrame.location.replace( szTopic );
- }
- else
- {
- mainFrame.location = szTopic;
- }
-
- var szOperation = "LoadHelpTopic( " + "'" + szTopic + "'" + ");";
- setTimeout( szOperation, 400, "JavaScript" );
- }
- else
- {
- if( true == g_bMSIE )
- {
- if( mainFrame.SynchToc )
- {
- mainFrame.SynchToc();
- }
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function DoHelp( szNesting, szTopic )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- if( document.pluginForm && document.pluginForm.help )
- {
- document.pluginForm.help.disabled = true;
- }
-
- var szFeatures = "location,hotkeys,scrollbars,status,resizable,menubar,toolbar";
- var szBaseHelpURL = szNesting;
-
- g_winHelp = window.open( "", "HELP", szFeatures, false );
- EatHelpCookie( szTopic );
-
- var bReload = false;
-
- if( true == g_bMSIE )
- {
- if( ( null == g_winHelp ) ||
- ( 3 != g_winHelp.frames.length ) ||
- ( null == g_winHelp.frames[ "treebody" ] ) ||
- ( null == g_winHelp.frames[ "treesrc" ] ) ||
- ( null == g_winHelp.frames[ "main" ] ) )
- {
- bReload = true;
- }
- }
- else
- {
- if( ( null == g_winHelp ) ||
- ( 2 != g_winHelp.frames.length ) ||
- ( null == g_winHelp.frames[ "main" ] ) )
- {
- bReload = true;
- }
- }
- if( bReload )
- {
- g_winHelp = window.open( szNesting + "help/default.htm", "HELP", szFeatures, false );
- }
- if( g_winHelp )
- {
- EatHelpCookie( szTopic );
- // g_winHelp.document.SetDefaultOpenTreeNodes();
- // g_winHelp.document.InitTree();
-
- g_winHelp.name = "HELP";
- g_winHelp.focus();
-
- LoadHelpTopic( szTopic );
-
- if( document.pluginForm && document.pluginForm.help )
- {
- document.pluginForm.help.disabled = false;
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function DoPluginHelp()
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var szFeatures = "location,hotkeys,scrollbars,status,resizable,menubar,toolbar";
-
- g_winHelp = window.open( "../../help/default.htm", "HELP", szFeatures, false );
- if( g_winHelp )
- {
- g_winHelp.name = "HELP";
- g_winHelp.focus();
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function ShowServerList()
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- window.open( "/wmssecure/index.asp?show=true", "sList", "hotkeys,scrollbars,status,menubar,resizable", true );
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function DoRefresh()
- {
- var eachChildFrame;
- var numFrames;
- var childFrame;
- var bUpdatesPerformed;
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- bUpdatesPerformed = false;
-
- childFrame = parent.frames && parent.frames[ "treeFrames" ];
- if( childFrame )
- {
- childFrame = window.parent.frames[ "treeFrames" ].frames[ "frameTreeCode" ];
- }
- if( childFrame )
- {
- childFrame.location.replace( childFrame.location );
- bUpdatesPerformed = true;
- }
-
- childFrame = window.parent.frames[ "frameDetails" ];
- if( childFrame )
- {
- childFrame.location.replace( childFrame.location );
- bUpdatesPerformed = true;
- }
-
- childFrame = window.top.frames[ "WMSSession" ];
- if( childFrame )
- {
- childFrame.location = childFrame.location;
- bUpdatesPerformed = true;
- }
-
- if( bUpdatesPerformed )
- {
- return;
- }
-
- eachChildFrame = 0;
- if ( window.parent )
- {
- numFrames = window.parent.frames.length;
- }
- else
- {
- numFrames = window.frames.length;
- }
-
- if( 0 < numFrames )
- {
- for( eachChildFrame = 0; eachChildFrame < numFrames; eachChildFrame++ )
- {
- if( window.parent )
- {
- childFrame = window.parent.frames[ eachChildFrame ];
- }
- else
- {
- childFrame = window.frames[ eachChildFrame ];
- }
-
- if( childFrame )
- {
- if( childFrame.location )
- {
- childFrame.location.replace( childFrame.location );
- }
- }
- }
- }
- else
- {
- if( 0 != g_dwLastTimerTask )
- {
- window.clearTimeout( g_dwLastTimerTask );
- g_dwLastTimerTask = 0;
- }
- document.location.replace( document.location );
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- ///////////////////////////
- function UpdateTreeView()
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var eachChildFrame;
- var numFrames;
- var childFrame;
- if( window.parent && window.parent.frames && window.parent.frames[ "treeFrames" ] && window.parent.frames[ "treeFrames" ].frames )
- {
- childFrame = window.parent.frames[ "treeFrames" ].frames[ "frameTreeCode" ];
- }
-
- if( childFrame )
- {
- childFrame.location.replace( childFrame.location );
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
-
- ///////////////////////////
- function SetRefreshRate( caller )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- if( document.RefreshInterval )
- {
- document.RefreshInterval.submit();
- }
- else
- {
- caller.submit();
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-
- g_rgDivVisited = null; //new Array( 0 );
-
- ///////////////////////////
- function InArrayAtIndex( theDiv )
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var i, len, element, szID_A, szID_B;
- len = g_rgDivVisited.length;
-
- if( ( null == g_rgDivVisited ) || ( null == theDiv ) )
- {
- return( -1 );
- }
-
- szID_A = new String( theDiv.id );
-
- for( i = 0; i < len; i++ )
- {
- element = g_rgDivVisited[ i ];
- if( null != element )
- {
- szID_B = element.id;
- if( szID_A == szID_B )
- {
- return( i );
- }
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return( -1 );
- }
-
- ///////////////////////////
- function RecordMouseOverInArray( szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- if( ! g_rgDivVisited )
- {
- g_rgDivVisited = new Array( theDiv );
- }
- else
- {
- if( -1 == InArrayAtIndex( theDiv ) )
- {
- g_rgDivVisited[ g_rgDivVisited.length ] = theDiv;
- // DumpIDsInArray();
- }
- RestoreAllButThis( szName );
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function OnMouseLeave( dwWhichItem, szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- ResetToolbarEntry( szName );
- theDiv.releaseCapture();
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function OnMouseDown( dwWhichItem, szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- RecordMouseOverInArray( szName );
- theDiv.setCapture();
-
- var szOuterHTML = new String( theDiv.outerHTML );
- if( -1 != szOuterHTML.indexOf( "toolbarnormal" ) )
- {
- /*
- if( theDiv.className != "toolbardepressed" )
- {
- theDiv.className = "toolbardepressed";
- }
- */
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function OnMouseUp( dwWhichItem, szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- RecordMouseOverInArray( szName );
- theDiv.setCapture();
-
- var szOuterHTML = new String( theDiv.outerHTML );
- if( -1 != szOuterHTML.indexOf( "toolbarnormal" ) )
- {
- theDiv.style.backgroundColor = "white";
- if( theDiv.className != "toolbarnormal" )
- {
- theDiv.className = "toolbarnormal";
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function OnMouseEnter( dwWhichItem, szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- RecordMouseOverInArray( szName );
- theDiv.setCapture();
-
- var szOuterHTML = new String( theDiv.outerHTML );
- if( -1 != szOuterHTML.indexOf( "toolbarnormal" ) )
- {
- if( theDiv.className != "toolbarhover" )
- {
- theDiv.className = "toolbarhover";
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function OnClickToolbar( dwWhichItem, szName, szLinkName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theLink = document.all[ szLinkName ];
- if( theLink )
- {
- theLink.click();
- }
-
- var theDiv = document.all[ szName ];
- if( theDiv )
- {
- if( theDiv.className != "toolbarnormal" )
- {
- theDiv.className = "toolbarnormal";
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- function ResetToolbarEntry( dwWhichItem, szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- if( ! theDiv )
- {
- return;
- }
-
- var szOuterHTML = new String( theDiv.outerHTML );
- if( -1 != szOuterHTML.indexOf( "toolbarhover" ) )
- {
- if( theDiv.className != "toolbarnormal" )
- {
- theDiv.className = "toolbarnormal";
- }
-
- var i = InArrayAtIndex( theDiv );
- if( -1 != i )
- {
- if( 0 < i )
- {
- var rgA, rgB;
- rgA = g_rgDivVisited.slice( 0, i-1 );
- rgB = g_rgDivVisited.slice( i+1, g_rgDivVisited.length );
- g_rgDivVisited = rgA.concat( rgB );
- }
- else
- {
- g_rgDivVisited = g_rgDivVisited.slice( i + 1, g_rgDivVisited.length );
- }
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
- ///////////////////////////
- // useful for debugging toolbar array
- //
- function DumpIDsInArray()
- {
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var szVisited = new String( "visited: " );
- for( i = 0; i < g_rgDivVisited.length; i++ )
- {
- var objElement = g_rgDivVisited[ i ];
- szVisited += objElement.name
- }
- window.status = szVisited;
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- return;
- }
-
-
- ///////////////////////////
- function RestoreAllButThis( szName )
- {
- if( ! g_bMSIE )
- {
- return;
- }
-
- /*@if (@_jscript_version >= 1.3)
- try
- {
- @end @*/
- var theDiv = document.all[ szName ];
- var i, len;
- var szID_A, szID_B;
- var objElement;
-
- if( ! g_rgDivVisited || ! theDiv )
- {
- return;
- }
-
- szID_A = new String( theDiv.id );
-
- len = g_rgDivVisited.length;
- for( i = 0; i < len; i++ )
- {
- objElement = g_rgDivVisited[ i ];
-
- if( objElement )
- {
- szID_B = new String( objElement.id );
- if( szID_A != objElement.id )
- {
- ResetToolbarEntry( szID_B );
- }
- }
- }
- /*@if (@_jscript_version >= 1.3)
- }
- catch( error )
- {
- if( g_bDebugMode ) { throw( error ); }
- }
- @end @*/
- }
-